package com.hw.elasticsearch.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

@Document(indexName="users",type="user",shards=1,replicas=0)
public class User {

//	jackson的反序列化需要无参构造函数，否则报错
	public User() {};
	
	public User(Long id,String name, int age, String sex) {
		this.id=id;
		this.name = name;
		this.age = age;
		this.sex = sex;
	}

	@Id
	private Long id;
	@Field(type=FieldType.Text,analyzer="ik_max_word")
	private String name;
	@Field(type=FieldType.Integer)
	private int age;
	@Field(type=FieldType.Text,analyzer="ik_max_word")
	private String sex;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", name=" + name + ", age=" + age + ", sex=" + sex + "]";
	}	
	
}
